#include <iostream>
#include <fstream>
#include <time.h>

using namespace std;

int primeNumbers[2500];
int size = 0;
int years[2500];

bool isPrimeNumber(int possiblePrime)
{
	bool isPrime = false;
	for(int i = 0; i < size; i++)
	{
		if(possiblePrime == primeNumbers[i])
			isPrime = true;
	}	
	return isPrime;
}

// Get current date/time, format is YYYY-MM-DD.HH:mm:ss
const string currentDateTime()
{
    time_t     now = time(0);
    struct tm  tstruct;
    char       buf[80];
    tstruct = *localtime(&now);

    strftime(buf, sizeof(buf), "%Y-%m-%d.%X", &tstruct);

    return buf;
}

int main()
{	
	for(int i =0; i < 2501; i++)
		years[i] = 1;

	years[0] = 0;
	years[1] = 0;

	for (int a = 2; a * a < 2501; a++)
		if(years[a] == 1)
			for(int b = a*a; b <= 2500; b+=a )
				years[b] = 0;

	for(int x = 0; x <2501; x++)
	{
		if(years[x] == 1)
		{
			primeNumbers[size] = x;
			size++;					
		}
	}

	ofstream primesFile;
	primesFile.open ("primes.txt");

	primesFile << "VERY IMPORTANT DATA ABOUT PRIMES OR SUMTHIN'" << endl;
	primesFile << "Created by: Marijn Stapert on: " << currentDateTime().c_str() << endl;

	for(int i = 0; i < size; i++)
	{
		int k = 0;
		for(int j =0; j < 11; j++)
		{
			k += primeNumbers[j+i];
		}		
		if(isPrimeNumber(k))
		{
			if(k>2011)
				primesFile << endl << "The next year that is a prime and a combination of 11 consecutive primes is: " << endl;												
			primesFile << k << " Made from : ";
			for(int l = 0; l < 11; l++)
			{
				primesFile << primeNumbers[l+i] << ", ";
			}
			if(k>2011)
				i = size;
			primesFile << endl;
		}
	}

	return 0;
}